import { baseURL } from '../axios.config'
import { get, post, Response } from '/@/api/http'
const serverContextPath = '/admin-server'

export const systemApi = {
	/**
	 * 验证码地址
	 * @param uuid 
	 * @returns 
	 */
	getCaptchaPath: (uuid: string) => {
		return baseURL + serverContextPath + `/sys/auth/captcha.jpg?uuid=${uuid}`
	},
	/**
	 * 登录
	 * @param username 用户名
	 * @param password 密码
	 * @param uuid 验证码校验码
	 * @param captcha 验证码
	 * @param terminal 终端pc-1 app-2
	 * @param tenantId 租户编号
	 * @param rememberMe 记住我
	 * @returns 
	 */
	login: (username: string, password: string, uuid: string, captcha: string, terminal: string, tenantId: string, rememberMe: boolean) => {
		return post({
			url: serverContextPath + '/sys/auth/login',
			data: {
				username: username,
				password: password,
				captcha: captcha,
				uuid: uuid,
				terminal: terminal,
				tenantId: tenantId,
				rememberMe: rememberMe,
			}
		})
	},
	/**
	 * 获取当前用户信息
	 * @returns 
	 */
	getUserInfoSession: () => {
		return get({
			url: serverContextPath + '/sys/auth/getUserInfoSession'
		})
	},
	/**
	 * 
	 * @returns 登出
	 */
	logout: () => {
		return post({
			url: serverContextPath + '/sys/auth/logout',
			data: {},
		})
	},
	/**
	 * 查询用户菜单
	 * @param terminal 终端
	 * @returns 
	 */
	getAllMenuForUser: (terminal: string) => {
		return get({
			url: serverContextPath + '/sys/auth/getAllMenuForUserVue/' + terminal,
		})
	},
	/**
	 * 当前登录用户的看板配置
	 * @returns 
	 */
	getCurrentDashboardSetting: () => {
		return get({
			url: serverContextPath + '/sys/auth/getCurrentDashboardSetting',
		})
	},
	/**
	 * 获取数据字典
	 * @returns 
	 */
	queryDicListAll: () => {
		return post({
			url: serverContextPath + '/sysDictionary/queryDicListAll',
			data: {},
		})
	},
	/**
	 * 获取数据字典
	 * @returns 
	 */
	getDicInfoById: (id: string) => {
		return get({
			url: serverContextPath + '/sysDictionary/getInfo/' + id,
		})
	},
	/**
	 * 根据类型编码查询数据字典
	 * @param classCode 类型编码
	 * @returns 
	 */
	getDicListByCode: (classCode: string) => {
		return get({
			url: serverContextPath + '/sysDictionary/getDicList/' + classCode,
		})
	},
	/**
	 * 分页查询数据字典
	 * @param data {
          page: pagination.page,
          pageSize: pagination.pageSize,
          param: searchForm,
        }
	 * @returns 
	 */
	queryDicListByPage: (data: any) => {
		return post({
      url: serverContextPath + '/sysDictionary/queryByPage',
      data: data,
    })
	},
	/**
	 * 新增数据字典
	 * @param dataForm 字典参数
	 * @returns 
	 */
	addDic: (dataForm: any) => {
		return post({
			url: serverContextPath + '/sysDictionary/addDic',
			data: dataForm,
		})
	},
	/**
	 * 修改数据字典
	 * @param dataForm 字典参数
	 * @returns 
	 */
	updateDic: (dataForm: any) => {
		return post({
			url: serverContextPath + '/sysDictionary/updateDic',
			data: dataForm,
		})
	},

	/**
	 * 删除数据字典
	 * @param id 主键
	 * @returns 
	 */
	deleteDic: (ids: string[]) => {
		return post({
			url: serverContextPath + '/sysDictionary/deleteDic',
			data: ids,
		})
	},
	/**
	 * 菜单列表，树形列表
	 * @returns 
	 */
	getMenuList: () => {
		return get({
			url: serverContextPath + '/sysMenu/getMenuList',
		})
	},

	/**
	 * 删除资源
	 * @param id 菜单id
	 * @returns {Promise<*>}
	 */
	deleteMenuInfo: (id: string) => {
		return get({
			url: serverContextPath + '/sysMenu/delete/' + id,
		})
	},
	/**
 	* 保存菜单数据
 	* @param data this.$http.adornData({
				'id': this.dataForm.id || undefined,
				'type': this.dataForm.type,
				'name': this.dataForm.name,
				'parentId': this.dataForm.parentId,
				'url': this.dataForm.url,
				'perms': this.dataForm.perms,
				'orderNum': this.dataForm.orderNum,
				'icon': this.dataForm.icon,
				'sysResource': this.dataForm.sysResource
				})
	* @returns {Promise<*>}
	*/
	saveMenuInfo: (data: any) => {
		return post({
			url: serverContextPath + '/sysMenu/save',
			data: data
		})
	},
	/**
 	* 修改菜单数据
 	* @param data this.$http.adornData({
				'id': this.dataForm.id || undefined,
				'type': this.dataForm.type,
				'name': this.dataForm.name,
				'parentId': this.dataForm.parentId,
				'url': this.dataForm.url,
				'perms': this.dataForm.perms,
				'orderNum': this.dataForm.orderNum,
				'icon': this.dataForm.icon,
				'sysResource': this.dataForm.sysResource
				})
	* @returns {Promise<*>}
	*/
	updateMenuInfo: (data: any) => {
		return post({
			url: serverContextPath + '/sysMenu/update',
			method: 'post',
			data: data
		})
	},
	/**
	 * 获取可用租户信息
	 * @returns 
	 */
	getTenantSelect: () => {
		return get({
			url: serverContextPath + '/sysTenant/getTenantSelect',
		})
	},
	/**
	 * 分页查询租户信息
	 * @param data 分页参数
	 * @returns 
	 */
	queryTenantListByPage: (data: any) => {
		return post({
      url: serverContextPath + '/sysTenant/page',
      data: data,
    })
	},
	/**
	 * 删除租户信息
	 * @param ids 主键数组
	 * @returns 
	 */
	deleteTenant: (ids: string[]) => {
		return post({
			url: serverContextPath + '/sysTenant/delete',
			data: ids,
		})
	},
	/**
	 * 新增租户
	 * @param dataForm 租户信息
	 * @returns 
	 */
	addTenant: (dataForm: any) => {
		return post({
			url: serverContextPath + '/sysTenant/save',
			data: dataForm,
		})
	},
	/**
	 * 修改租户
	 * @param dataForm 租户信息
	 * @returns 
	 */
	updateTenant: (dataForm: any) => {
		return post({
			url: serverContextPath + '/sysTenant/update',
			data: dataForm,
		})
	},
	/**
	 * 获取租户资源树
	 * @param id 角色id
	 * @returns {Promise<*>} data.tree 资源树，data.asingRes 选择节点
	 */
	getSysTenantResTree: (id: string) => {
		return get({
			url: serverContextPath + `/sysTenant/getSysTenantResTree/${id}`,
		})
	},
	/**
	 * 设置租户资源
	 * @param id 角色id
	 * @param resId 资源id数组
	 * @returns {*}
	 */
	setSysTenantMenu: (id:string, resId: any) => {
		return post({
			url: serverContextPath + `/sysTenant/setSysTenantMenu`,
			data: {
				'id': id,
				'resId': resId
			}
		})
	},
	/**
	 * 获取机构树，超级管理员获取全部，其他只获取自己租户的机构
	 * @param tenantId 
	 * @returns 
	 */
	getOrgsByTenantId: (tenantId: string) => {
		return get({
			url: serverContextPath + '/sysOrg/treeList/' + tenantId,
		})
	},
	/**
	 * 获取租户下的机构树
	 * @param tenantId 
	 * @returns 
	 */
	treeListByTenantId: (tenantId: string) => {
		return get({
			url: serverContextPath + '/sysOrg/treeListByTenantId/' + tenantId,
		})
	},
	/**
	 * 根据id删除机构
	 * @param id 
	 * @returns 
	 */
	deleteOrgById: (id: string) => {
		return get({
			url: serverContextPath + '/sysOrg/remove/' + id,
		})
	},
	/**
	 * 保存机构数据
	 * @param data 
	 * @returns 
	 */
	saveOrg: (data: any) => {
		return post({
			url: serverContextPath + '/sysOrg/save',
			data: data
		})
	},
	/**
	 * 修改机构数据
	 * @param data 
	 * @returns 
	 */
	updateOrg: (data: any) => {
		return post({
			url: serverContextPath + '/sysOrg/update',
			data: data
		})
	},
	/**
	 * 分页查询岗位信息
	 * @param params 
	 * @returns 
	 */
	queryStationList: (params: any) => {
		return post({
			url: serverContextPath + '/sysStation/page',
			method: 'post',
			data: params
		})
	},
	/**
	 * 获取资岗位源树，当前人员有权限的资源树或者自己租户的资源
	 * @param tenantId 租户id
	 * @param id 岗位id
	 * @returns {Promise<*>} data.tree 资源树，data.asingRes 选择节点
	 */
	getTenantStationResTree: (tenantId: string, id: string) => {
		return post({
			url: serverContextPath + '/sysStation/getTenantStationResTree',
			data: {
				'tenantId': tenantId,
				'id': id || ''
			}
		})
	},
	/**
	 * 删除岗位信息
	 * @param ids 
	 * @returns 
	 */
	deleteStation: (ids: string[]) => {
		return post({
			url: serverContextPath + '/sysStation/delete',
			data: ids,
		})
	},
	/**
	 * 批量删除岗位的资源权限
	 * @param ids 
	 * @returns 
	 */
	deleteStationRes: (ids: string[]) => {
		return post({
			url: serverContextPath + '/sysStation/deleteStationRes',
			data: ids
		})
	},
	/**
	 * 保存岗位信息
	 * @param data 
	 * @returns 
	 */
	saveStation: (data: any) => {
		return post({
			url: serverContextPath + '/sysStation/save',
			data: data
		})
	},
	/**
	 * 保存岗位信息
	 * @param data 
	 * @returns 
	 */
	updateStation: (data: any) => {
		return post({
			url: serverContextPath + '/sysStation/update',
			data: data
		})
	},
	/**
	 * 保存岗位资源权限
	 * @param id 
	 * @param resId 
	 * @returns 
	 */
	saveStationRes: (id: string, resId: any) => {
		return post({
			url: serverContextPath + '/sysStation/saveStationRes',
			method: 'post',
			data: {
				'id': id,
				'resId': resId
			}
		})
	},
	/**
	 * 系统日志查询
	 * @param data 查询条件
	 * @returns 
	 */
	querySysLogListByPage: (data: any) => {
		return post({
			url: serverContextPath + '/sysLog/queryByPage',
			data: data
		})
	},
	/**
	 * 分页查询角色
	 * @param data 
	 * @returns 
	 */
	queryRoleListPage: (data: any) => {
		return post({
			url: serverContextPath + '/sysRole/queryRoleListPage',
			data: data
		})
	},
	/**
	 * 删除角色
	 * @param id 
	 * @returns 
	 */
	deleteSysRoleInfo: (id: string) => {
		return get({
			url: serverContextPath + '/sysRole/remove/' + id,
		})
	},
	/**
		 * 租户下角色资源权限，只能选择租户下的资源范围
		 * @param {租户id} tenantId 
		 * @param {角色id} id 角色id决定是否有选中
		 */
	resetTenantRoleResTree: (tenantId:string, id:any) => {
		return get({
			url: serverContextPath + `/sysRole/resetTenantRoleResTree/${tenantId}/${id}`,
		})
	},

	/**
		 * 新增角色
		 * @param data
		 * @returns {*}
		 */
	saveSysRoleInfo: (data: any) => {
		return post({
			url: serverContextPath + `/sysRole/save`,
			data: data
		})
	},

	/**
	 * 修改角色
	 * @param data
	 * @returns {*}
	 */
	updateSysRoleInfo: (data: any) => {
		return post({
			url: serverContextPath + `/sysRole/update`,
			data: data
		})
	},
	/**
		 * 设置角色资源
		 * @param id 角色id
		 * @param resId 资源id数组
		 * @returns {*}
		 */
	setSysRoleMenu: (id: any, resId: any) => {
		return post({
			url: serverContextPath + `/sysRole/setRoleMenu`,
			method: 'post',
			data: {
				'id': id,
				'resId': resId
			}
		})
	},
	/**
	 * 查询角色下的用户，分页
	 * @param data 
	 * @returns 
	 */
	getRoleUserDataListByRoleId: (data: any) => {
		return post({
			url: serverContextPath + '/sysRole/getRoleUserDataListByRoleId',
			data: data
		})
	},
	/**
	 * 删除用户角色关系
	 * @param id 
	 * @returns 
	 */
	deleteRoleUserById: (id: string) => {
		return get({
			url: serverContextPath + '/sysRole/deleteRoleUserById/' + id,
		})
	},
	/**
	 * 查询未设置该角色的用户
	 * @param data 
	 * @returns 
	 */
	getRoleUserSelectListByRoleId: (data: any) => {
		return post({
			url: serverContextPath + '/sysRole/getRoleUserSelectListByRoleId',
			data: data
		})
	},
	/**
	 * 新增用户角色关系 
	 * @param data 
	 * @returns 
	 */
	setRoleUserSelectHandle: (data: any) => {
		return post({
			url: serverContextPath + '/sysRole/setRoleUserSelectHandle',
			data: data
		})
	},
	/**
	 * 获取当前用户租户下的角色
	 * @returns 
	 */
	getTenantRoleList: () => {
		return get({
			url: serverContextPath + '/sysRole/getTenantRoleList'
		})
	},
	/**
	 * 分页查询用户信息
	 * @param data 
	 * @returns 
	 */
	querySysUserListPage: (data: any) => {
		return post({
			url: serverContextPath + '/sysUser/page',
			data: data
		})
	},
	/**
	 * 根据主键删除用户信息
	 * @param id 
	 * @returns 
	 */
	deleteSysUserInfo: (id: string) => {
		return post({
			url: serverContextPath + '/sysUser/remove/' + id,
		})
	},
	/**
	 * 新增用户信息
	 * @param data 
	 * @returns 
	 */
	saveSysUserInfo: (data: any) => {
		return post({
			url: serverContextPath + `/sysUser/save`,
			data: data
		})
	},
	/**
	 * 修改用户信息
	 * @param data 
	 * @returns 
	 */
	updateSysUserInfo: (data: any) => {
		return post({
			url: serverContextPath + `/sysUser/update`,
			data: data
		})
	},
	/**
	 * 管理员重置密码
	 * @param id 
	 * @returns 
	 */
	resetPasswordByUserId: (id: string) => {
		return post({
			url: serverContextPath + '/sysUser/resetPassword/' + id,
		})
	},
	/**
	 * 根据用户名查询用户信息
	 * @param data 
	 * @returns 
	 */
	queryUserByName: (data: any) => {
		return post({
			url: serverContextPath + '/sysUser/queryUserByName',
			data: data
		})
	},
	/**
	 * 根据用户id获取关联角色
	 * @param id 
	 * @returns 
	 */
	getUserRolesByUserId: (id: string) => {
		return get({
			url: serverContextPath + '/sysUser/getUserRolesByUserId/' + id,
		})
	},
	/**
	 * 设置用户角色信息
	 * @param userId 
	 * @param roleList 
	 * @returns 
	 */
	setUserRolesByUserId: (userId: string, roleList: []) => {
		return post({
			url: serverContextPath + '/sysUser/setUserRolesByUserId',
			data:{
				'id': userId,
				'roleIds': roleList,
			}
		})
	},
	/**
	 * 获取用户岗位信息
	 * @param id 
	 * @returns 
	 */
	getUserStationTree: (id: string) => {
		return get({
			url: serverContextPath + '/sysUser/getUserStationTree/' + id,
		})
	},
	/**
	 * 根据租户获取用户岗位信息
	 * @param tenantId 
	 * @returns 
	 */
	 getUserStationTreeByTenant: (tenantId: string) => {
		return get({
			url: serverContextPath + '/sysUser/getUserStationTreeByTenant/' + tenantId,
		})
	},
	/**
	 * 设置用户岗位
	 * @param userId 
	 * @param stationList 
	 * @returns 
	 */
	setUserStationByUserId: (userId: string, stationList: any) => {
		return post({
			url: serverContextPath + '/sysUser/setUserStationByUserId',
			data:{
				'id': userId,
				'stationIds': stationList,
			}
		})
	},
	getTenantUserResTree: (tenantId:string, id:any) => {
		return get({
			url: serverContextPath + `/sysUser/getTenantUserResTree/${tenantId}/${id}`,
		})
	},
	setUserMenuByUserId: (userId: string, menuIdList: any) => {
		return post({
			url: serverContextPath + '/sysUser/setUserMenuByUserId',
			data:{
				'id': userId,
				'menuIds': menuIdList,
			}
		})
	},
	/**
	 * 分页查询参数
	 * @param data {
          page: pagination.page,
          pageSize: pagination.pageSize,
          param: searchForm,
        }
	 * @returns 
	*/
	querySysConfigListPage: (data: any) => {
		return post({
			url: serverContextPath + '/sysConfig/page',
			data: data,
		})
	},
	/**
	 * 新增参数
	 * @param dataForm 参数
	 * @returns 
	 */
	saveSysConfigInfo: (dataForm: any) => {
		return post({
			url: serverContextPath + '/sysConfig/save',
			data: dataForm,
		})
	},
	/**
	 * 修改参数
	 * @param dataForm 参数
	 * @returns 
	 */
	updateSysConfigInfo: (dataForm: any) => {
		return post({
			url: serverContextPath + '/sysConfig/update',
			data: dataForm,
		})
	},

	/**
	 * 删除参数
	 * @param id 主键
	 * @returns 
	 */
	deleteSysConfigInfo: (id: string) => {
		return post({
			url: serverContextPath + '/sysConfig/remove/' + id,
		})
	},
	getAllUserBySelfTenant: () => {
		return get({
			url: serverContextPath + '/sysUser/getAllUserBySelfTenant',
		})
	},
	/**
     * 分页查询首页看板设置
     * @param data {
          page: pagination.page,
          pageSize: pagination.pageSize,
          param: {...},
        }
     * @returns
     */
	querySysDashboardSettingListPage: (data: any) => {
		return post({
			url: serverContextPath + '/sysDashboardSetting/page',
			data: data,
		})
	},
	/**
	 * 新增首页看板设置
	 * @param dataForm 参数
	 * @returns
	 */
	saveSysDashboardSettingInfo: (dataForm: any) => {
		return post({
			url: serverContextPath + '/sysDashboardSetting/save',
			data: dataForm,
		})
	},
	/**
	 * 修改首页看板设置
	 * @param dataForm 参数
	 * @returns
	 */
	updateSysDashboardSettingInfo: (dataForm: any) => {
		return post({
			url: serverContextPath + '/sysDashboardSetting/update',
			data: dataForm,
		})
	},

	/**
	 * 删除首页看板设置
	 * @param id 主键
	 * @returns
	 */
	deleteSysDashboardSettingInfo: (id: string) => {
		return post({
			url: serverContextPath + '/sysDashboardSetting/remove/' + id,
		})
	},
}